<template>
  <div class="NewsDetail">
    <!-- <van-nav-bar
      title="入会须知"
      left-arrow
      @click-left="backHome"
    /> -->
    <nav-bar :title="'入会须知'"></nav-bar>
    <div class="wrap">
      <div class="NewsDetail-content rich v-html-img" v-html="notice"></div>
    </div>
    <div class="applyButton" @click="applyVip()">同意并申请入会</div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import navBar from "@/components/NavBar";
export default {
  components: {
    navBar,
  },
  name: "NewsDetail",
  computed: {
    ...mapGetters(["userInfo"]),
  },
  data() {
    return {
      imgUrl: config.imgUrl,
      notice: "",
    };
  },
  methods: {
    backHome() {
      this.$router.back();
    },
    findNotice() {
      this.$request({
        url: "/notic/findNoticByType",
        data: { type: 1 },
        method: "post",
      }).then((rsp) => {
        if (rsp.code === 200) {
          console.log(rsp.data);
          this.notice = rsp.data.content;
        } else {
          this.$toast.fail(rsp.content);
        }
      });
    },
    applyVip() {
      if (this.userInfo && this.userInfo.userCode) {
        this.$router.push({ path: "/vip" });
      } else {
        this.$dialog
          .confirm({
            title: "",
            message: "您需要登陆才能继续访问内容,您是否要登陆?",
          })
          .then(() => {
            this.$router.push({
              path: "/login",
            });
          })
          .catch(() => {
            this.$router.back(-1);
          });
      }
    },
  },
  mounted() {
    this.findNotice();
  },
};
</script>
<style scoped>
.rich >>> img {
  width: 100%;
  height: 100%;
}
</style>
<style lang='scss'>
@import "../assets/css/base";

.NewsDetail {
  &-title {
    margin-top: px2rem(46);
    font-size: px2rem(40);
    color: #000000;
    font-weight: 500;
  }
  &-note {
    margin-top: px2rem(20);
    margin-bottom: px2rem(35);
    color: #808080;
    font-size: px2rem(20);
    display: flex;
    & > span {
      padding-left: px2rem(10);
      padding-right: px2rem(10);
    }
  }
  &-content {
    & > img {
      width: 100%;
      border-radius: px2rem(5);
      margin-bottom: px2rem(20);
    }
    & > p {
      font-size: px2rem(24);
      color: #333333;
      line-height: 1.8;
      margin-bottom: px2rem(30);
    }
  }
  .applyButton {
    color: #fff;
    background: $mainColor;
    position: fixed;
    bottom: 0;
    height: px2rem(100);
    text-align: center;
    width: 100%;
    line-height: px2rem(100);
    font-size: px2rem(36);
  }
}
</style>
